object hello {

  def people(names: List[String]) =
    names.init.mkString(", ") + ", and " + names.last


  /*def people(names: List[String]): String =
    // @unchecked keeps Scala from complaining about Nil case.
    (names: @unchecked) match {
      case only :: Nil => "and " + only
      case x :: xs => x + ", " + people(xs)
    }*/


  def main(args: Array[String]) {
    val greet = args match {
      case Array() => "World"
      case Array(x) => x
      case _ => people(args.toList)
    }

    println("Hello, " + greet + "!")

  }

}
